<template>
  <div class="housing">
    <header>
      <p>
        <router-link to="/">《——</router-link>
      </p>
      <p>楼市圈</p>
      <p>
        <span>...</span>
        <span>o</span>
      </p>
    </header>
    <main>
      <div class="housingring" v-for="(item, index) in housingRing" :key="index">
        <!-- 头像 -->
        <dl>
          <dt>
            <img :src="item.img" alt />
          </dt>
          <dd>{{item.name}}</dd>
        </dl>

        <!-- 图片 -->
        <dl>
          <dd>
            <h3>
              <p>四月</p>
              <p>{{item.time}}</p>
            </h3>

            <h2>{{item.title}}</h2>
          </dd>
          <dt>
            <img :src="item.imglist" alt />
          </dt>
          <dd>
            <p class="p" @click="Del(item.id)">删除</p>
          </dd>
        </dl>
      </div>
      <router-link to="/publishroom">
           <div class="addhousing">
          <i class="el-icon-circle-plus-outline"></i>
      </div>
      </router-link>
     
    </main>
  </div>
</template>

<script>
import { housingRing } from "../../../api/index";
import axios from "axios";

export default {
  data() {
    return {
      housingRing: []
    };
  },
  created() {
    this.housingring();
  },
  methods: {
    housingring() {
      housingRing().then(res => {
        if (res.data.code === 0) {
          this.$router.push("/login");
          this.$toast(res.data.msg);
        } else {
          this.housingRing = res.data.data;
        }
      });
    },

    //删除数据
    Del(id) {
      axios({
        url: "/api/housingRingDel",
        method: "post",
        data: {
          id: id
        }
      }).then(res => {
        //调用函数
        this.housingring();
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.housing {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  header {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 60px;
    background-color: rgb(34, 100, 177);
    color: #fff;

    p:first-child {
      a {
        color: #fff;
      }
    }
    p:nth-child(3) {
      border: 1px solid rgb(226, 226, 226);
      width: 60px;
      height: 26px;
      border-radius: 26px;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }
  }

  main {
    flex: 1;
    overflow-y: scroll;
    .housingring {
      width: 90%;
      height: 300px;
      margin: 50px auto;
      border: 1px solid rgb(243, 243, 243);
      dl:first-child {
        display: flex;
        align-items: center;

        dt {
          img {
            width: 50px;
            height: 50px;
            border-radius: 50px;
          }
        }
        dd {
          font-size: 20px;
          font-weight: bold;
        }
      }
      dl:nth-child(2) {
        // display: flex;
        // align-items: center;
        dd {
          display: flex;
          h3 {
            p:first-child {
              font-size: 25px;
              font-weight: bold;
            }
          }

          h2 {
            font-size: 24px;
            font-weight: bold;
          }
          .p {
            font-size: 20px;
            color: blue;
            margin: 0 auto;
          }
        }
        dt {
          img {
            width: 90%;
            height: 150px;
            margin-left: 8%;
            border-radius: 10px;
          }
        }
      }
    }
    .addhousing{
        position: fixed;
        border-radius: 40px;
        right: 40px;
        bottom: 40px;
        background-color: blue;
        i{
            font-size: 50px;
            color: #fff;
        }
    }
  }
}
</style>